package com.qhhc.service.impl;

import com.qhhc.entity.Car;
import com.qhhc.mapper.CarMapper;
import com.qhhc.service.ICarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class CarService implements ICarService {
    @Autowired
    CarMapper carMapper;
    
    @Override
    public int insert(Car car) {
        int count = carMapper.insertCar(car);
        return count;
    }
    
    @Override
    public List<Car> selectAll() {
        List<Car> cars = carMapper.selectAllCars();
        return cars;
    }
    
    @Override
    public Car selectById(Long id) {
        Car car = carMapper.selectCarById(id);
        System.out.println(car.toString());
        return car;
    }
    
    @Override
    public int update(Car car) {
        return carMapper.updateCar(car);
    }
    
    @Override
    public int delete(Long id) {
        return carMapper.deleteCar(id);
    }
}
